# -*- encoding: utf-8 -*-
"""

PyCharm matplotlib库的使用
2024年10月22日21时09分
by wenyang

文件主要内容:


"""
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D


def main():
    x = np.arange(0, 100, 1)
    y = np.random.randn(100) * 10
    plt.plot(x, y, "x")


    image = np.random.rand(30, 30)
    plt.imshow(image, cmap = plt.cm.hot)
    plt.colorbar()

    fig = plt.figure()
    ax = Axes3D(fig)
    X = np.arange(-4, 4, 0.25)
    Y = np.arange(-4, 4, 0.25)
    X, Y = np.meshgrid(X, Y)
    R = np.sqrt(X ** 2 + Y ** 2)
    Z = np.sin(R)
    ax.plot_surface(X, Y, Z, rstride = 1, cstride = 1, cmap = plt.cm.hot)
    ax.contourf(X, Y, Z, zdir = "z", offset = -2, cmap = plt.cm.hot)
    ax.set_zlim(-2, 2)
    plt.xticks(())
    plt.yticks(())
    ax.set_zticks(())
    ax.text2D(0.05, 0.95, "3D Surface Plot", transform = ax.transAxes)
    ax.text2D(0.05, 0.9, "by wenyang", transform = ax.transAxes)
    plt.title("3D Surface Plot")
    plt.xlabel("X")
    plt.ylabel("Y")
    plt.show()





if __name__ == "__main__":
    main()
